package 
{
	import component.CmpWraper;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import keyctrl.KeyManager;
	
	import util.err.SingletonInstantiationErr;

	public class CanvasManager
	{
		private static var _instance:CanvasManager;
		
		private var _cmps:Array;
		
		private var _uiStage:Sprite;
		
		private var _choosingCmps:Array;
		
		public function CanvasManager()
		{
			if( _instance ) throw new SingletonInstantiationErr();
		}
		
		public static function instance():CanvasManager
		{
			if( !_instance ) _instance = new CanvasManager();
			return _instance;
		}
		
		public function init( uiStage:Sprite ):void
		{
			this._uiStage = uiStage;
			
			_cmps = [];
			
		}
		
		
		public function register( cmp:CmpWraper ):void
		{
			_cmps.push( cmp );
			
			configListener( cmp );
		}
		
		
		public function configListener( cmp:CmpWraper ):void
		{
			cmp.addEventListener( MouseEvent.CLICK, cmpClickHandler );	
		}
		
		
		private function cmpClickHandler( e:MouseEvent ):void
		{
			if( !KeyManager.SHIFT_DOWN )
			{
				clearCurrentSelection();
			}
			
			selected( e.currentTarget as CmpWraper );
		}
		
		private function clearCurrentSelection():void
		{
			
		}
		
		private function selected( cmp:CmpWraper ):void
		{
			
		}
		
		
		
	}
}